package com.talent.service.iot.mqtt.codec.decoder;

import com.talent.service.iot.mqtt.model.fix.TlMqttFixedHead;
import com.talent.service.iot.mqtt.model.request.TlMqttDisconnectReq;
import io.netty.handler.codec.mqtt.MqttMessageType;
import org.springframework.stereotype.Component;

/**
 * @ClassName：TlConnectDecoder
 * @Author: hszhou
 * @Date: 2024/11/30 15:12
 * @Description: 断开连接报文解码器
 */
@Component
public class TlMqttDisConnectDecoder {

    public TlMqttDisconnectReq build( int remainingLength){
        TlMqttFixedHead fixedHead = decodeFixedHeader( remainingLength);
        return new TlMqttDisconnectReq(fixedHead);
    }
    TlMqttFixedHead decodeFixedHeader(int remainingLength) {
        TlMqttFixedHead fixedHead =new TlMqttFixedHead();
        fixedHead.setMessageType(MqttMessageType.DISCONNECT);
        fixedHead.setLength(remainingLength);
        return fixedHead;
    }
}
